﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

using Hangjing.Common;
using Hangjing.SQLServerDAL;
using Hangjing.Model;
using Hangjing.DBUtility;
using Hangjing.WebCommon;

// 订单信息管理
// CopyRight (c) 2009-2010 HangJing Teconology. All Rights Reserved.
// zjf@ihangjing.com 
// 2011-06-10

public partial class Admin_shop_historyOrderList : AdminPageBase
{
    private string SqlWhere
    {
        get
        {
            object o = ViewState["SqlWhere"];
            return (o == null) ? "" : Convert.ToString(o);
        }
        set
        {
            ViewState["SqlWhere"] = value;
        }
    }

    protected string ordersort
    {
        get
        {
            object o = ViewState["ordersort"];
            return (o == null) ? "unid" : Convert.ToString(o);
        }
        set
        {
            ViewState["ordersort"] = value;
        }
    }

    Custorder bll = new Custorder();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            tbStartTime.Text = DateTime.Now.ToShortDateString();
            this.tbEndTime.Text = DateTime.Now.ToShortDateString() + "";
            WebUtility.SetDDLCity(DDLArea);
            new OrderState().BindOrderState(ddlOrderState);

            string start = Request.QueryString["start"];
            if (start != null && start.Length > 0)
            {
                tbStartTime.Text = start;
            }

            string end = Request.QueryString["end"];
            if (end != null && end.Length > 0)
            {
                tbEndTime.Text = end;
            }

            EnumHelper.OrderSourceToDropDownList(ddlsource);
            initwhere();
            BindData(ordersort);
        }
    }

    /// <summary>
    /// 时间变化搜索
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void settime_Click(object sender, EventArgs e)
    {
        DateTime dt = DateTime.Now; //当前时间
        string starttime = this.tbStartTime.Text;
        string endtime = this.tbEndTime.Text;
        Button bt = (Button)sender;
        switch (bt.ID)
        {
            case "btpre"://前一天
                if (starttime != "")
                {
                    tbStartTime.Text = Convert.ToDateTime(starttime).AddDays(-1).ToShortDateString() + "";
                }
                else
                {
                    return;
                }
                if (endtime != "")
                {
                    tbEndTime.Text = Convert.ToDateTime(endtime).AddDays(-1).ToShortDateString() + "";
                }
                else
                {
                    return;
                }
                break;
            case "btyestoday"://昨天
                tbStartTime.Text = DateTime.Now.AddDays(-1).ToShortDateString() + "";
                tbEndTime.Text = DateTime.Now.AddDays(-1).ToShortDateString() + "";

                break;
            case "tbtoday"://今天
                tbStartTime.Text = DateTime.Now.ToShortDateString() + "";
                tbEndTime.Text = DateTime.Now.ToShortDateString() + "";

                break;
            case "btnext"://后一天
                if (starttime != "")
                {
                    tbStartTime.Text = Convert.ToDateTime(starttime).AddDays(1).ToShortDateString() + "";
                }
                else
                {
                    return;
                }
                if (endtime != "")
                {
                    tbEndTime.Text = Convert.ToDateTime(endtime).AddDays(1).ToShortDateString() + "";
                }
                else
                {
                    return;
                }
                break;
            case "tbweek"://本周

                DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d")));
                tbStartTime.Text = startWeek.ToDate();

                tbEndTime.Text = DateTime.Now.ToShortDateString() + "";
                break;
            case "tbmonth"://本月
                tbStartTime.Text = DateTime.Now.ToString("yyyy-MM-01") + "";
                tbEndTime.Text = DateTime.Now.ToShortDateString() + "";
                break;
            case "tbyear"://本年
                tbStartTime.Text = DateTime.Now.ToString("yyyy-01-01") + "";
                tbEndTime.Text = DateTime.Now.ToShortDateString() + "";

                break;
            default:
                break;
        }
        initwhere();

        BindData(ordersort);
    }


    /// <summary>
    /// 绑定指定的数据
    /// </summary>
    protected void BindData(string oo)
    {
        //Response.Write(SqlWhere);
        this.AspNetPager1.RecordCount =  bll.GetAdminOrdersCount(SqlWhere);
        IList<CustorderInfo> orders = bll.GetListFix(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, SqlWhere, "custorder.unid", 1);
        foreach (var item in orders)
        {
            item.ReveVar1 = "OrderDetail.aspx?id=" + item.Unid; 
            if (item.TogoId == 0)
            {
                item.ReveVar1 = "expressOrderDetail.aspx?id=" + item.Unid;
            }
        }

        this.rtpOrderlist.DataSource = orders;
        this.rtpOrderlist.DataBind();


        //保存此状态
        WebUtility.FixdelCookie("SearchOrderSqlWhere");

        AlertScript.AjaxRegisterScript("init();", UpdatePanel1);
        AlertScript.RegScript(this.Page, UpdatePanel1, " $('#loading-mask').hide();");
    }

    protected void btSearch_Click(object sender, EventArgs e)
    {
        initwhere();
        BindData(ordersort);
    }

    protected void initwhere()
    {
        SqlWhere = "1=1 and Custorder.delflag=0 ";

        SqlWhere = new RightsTool().getOrderWhere(SqlWhere);

        int deliverid = HjNetHelper.GetQueryInt("did", 0);
        if (deliverid > 0)
        {
            SqlWhere += " and deliverid=" + deliverid;
        }
        string cityid = WebUtility.FixgetCookie("admin_cityid");
        if (cityid != null && cityid != "" && cityid != "0")
        {
            SqlWhere += " and custorder.CityID = " + cityid + "  ";
        }
        if (tbTogoID.Text.Trim() != "")
        {
            SqlWhere += " and TogoId = " + tbTogoID.Text;
        }
        if (tborderid.Text != "")
        {
            SqlWhere += " and custorder.orderid like '%" + WebUtility.InputText(tborderid.Text) + "%'";
        }
        if (tbTogoName.Text != "")
        {
            SqlWhere = SqlWhere + " and EXISTS (SELECT Unid FROM dbo.Points WHERE Unid = dbo.Custorder.TogoId AND Name LIKE '%" + WebUtility.InputText(tbTogoName.Text) + "%')";
        }
        if (tbphone.Text != "")
        {
            SqlWhere += " and  OrderComm like '%" + Utils.RegEsc(WebUtility.InputText(this.tbphone.Text.Trim())) + "%' ";
        }
        if (tbOrderRcver.Text != "")
        {
            SqlWhere += " and  OrderRcver like '%" + Utils.RegEsc(WebUtility.InputText(this.tbOrderRcver.Text.Trim())) + "%' ";
        }
        if (tbdelivername.Text != "")
        {
            SqlWhere = SqlWhere + " and EXISTS (SELECT * FROM dbo.Deliver WHERE DataId = dbo.Custorder.deliverid AND Name LIKE '%" + WebUtility.InputText(tbdelivername.Text) + "%')";
        }


        if (tbStartTime.Text != "")
        {
            SqlWhere = SqlWhere + " and  custorder.OrderDateTime > '" + WebUtility.InputText(this.tbStartTime.Text) + "' ";
        }
        if (tbEndTime.Text != "")
        {
            SqlWhere = SqlWhere + " and  custorder.OrderDateTime <=  '" + WebUtility.InputText(this.tbEndTime.Text) + " 23:59:59'";

        }
        if (ddlOrderState.SelectedValue != "-1")
        {
            SqlWhere += " and OrderStatus = " + ddlOrderState.SelectedValue;
        }
        if (DDLArea.SelectedValue != "0")
        {
            SqlWhere += " and custorder.cityid = " + DDLArea.SelectedValue + "";
        }
        if (ddleatytpe.SelectedValue != "-1")
        {
            SqlWhere += " and ReveInt2 = " + ddleatytpe.SelectedValue;
        }
        if (ddlsource.SelectedValue != "-1")
        {
            SqlWhere += " and fromweb = " + ddlsource.SelectedValue;
        }

        if (ddlpaystate.SelectedValue != "-2")
        {
            SqlWhere += " and paystate=" + ddlpaystate.SelectedValue;
        }
        if (this.ddlpaymodel.SelectedValue != "-1")
        {
            SqlWhere = SqlWhere + " and paymode=" + ddlpaymodel.SelectedValue + "";
        }
        if (this.ddlIsShopSet.SelectedValue != "-1")
        {
            SqlWhere = SqlWhere + " and IsShopSet=" + ddlIsShopSet.SelectedValue + "";
        }

        if (this.ddlSystemUserId.SelectedValue != "-1")
        {
            SqlWhere = SqlWhere + " and SystemUserId=" + ddlSystemUserId.SelectedValue + "";
        }

        switch (ddlordertype.SelectedValue)
        {
            case "0":
                SqlWhere += " and TogoId = 0" ;
                break;
            case "1":
                SqlWhere += " and TogoId > 0";
                break;
            default:
                break;
        }

        switch (ddldispatchtype.SelectedValue)
        {
            case "-1":
                break;
            default:
                SqlWhere += " and OrderDeliver.Section = '" + ddldispatchtype.SelectedValue+"'";
                break;
        }




        if (this.ddlOrderChecker.SelectedValue != "-1")
        {
            SqlWhere = SqlWhere + " and OrderChecker=" + ddlOrderChecker.SelectedValue + "";
        }

        if (tbgroup.Text != "")
        {
            SqlWhere = SqlWhere + " and EXISTS (SELECT id FROM dbo.DeliverGroup WHERE id = dbo.Custorder.deliverheaderid AND classname LIKE '%" + WebUtility.InputText(tbgroup.Text) + "%') ";
        }
        if (tbinuse.Text.Trim() != "")
        {
            SqlWhere += " and custorder.inuse like '%" + WebUtility.InputText(tbinuse.Text) + "%'";

        }

        if (tbAddressText.Text.Trim() != "")
        {
            SqlWhere += " and AddressText like '%" + WebUtility.InputText(tbAddressText.Text) + "%'";

        }

        if (tbtimeout.Text.Trim() != "")
        {
            switch (rptsearchtype.SelectedValue)
            {
                case "0":
                    SqlWhere += " and OrderStatus in (1,2,7) and OrderDateTime <= '" + DateTime.Now.AddMinutes(-Convert.ToInt32(tbtimeout.Text)) + "'";
                    break;
                case "1":
                    SqlWhere += " and OrderStatus = 3 and Custorder.ReveInt1 >= " + WebUtility.InputText(tbtimeout.Text) + "";
                    break;
            }
        }

        if (tbsendtime.Text.Trim() != "")
        {
            switch (rblsendtimetype.SelectedValue)
            {
                case "0":
                    SqlWhere += " and OrderStatus in (1,2,7) and Custorder.deliverid > 0 and DeliveryTime <= '" + DateTime.Now.AddMinutes(-Convert.ToInt32(tbsendtime.Text)) + "'";
                    break;
                case "1":
                    SqlWhere += " and OrderStatus = 3 and DeliveryTime <= DATEADD(mi,"+ -Convert.ToInt32(tbsendtime.Text) + ",OverTime) " ;
                    break;
            }
        }


        if (tbOrderAttach.Text.Trim() != "")
        {
            SqlWhere += " and OrderAttach like '%" + WebUtility.InputText(tbOrderAttach.Text) + "%'";
        }
        if (tbOrderAddress.Text.Trim() != "")
        {
            SqlWhere += " and OrderAddress like '%" + WebUtility.InputText(tbOrderAddress.Text) + "%'";
        }

        if (tbcardids.Text.Trim() != "")
        {
            SqlWhere += " and cardids like '%" + WebUtility.InputText(tbcardids.Text) + "%'";
        }

        if (Request["tid"] != null && Request["tid"] != "0")
        {
            SqlWhere += " and TogoId = " + HjNetHelper.GetQueryString("tid") + "";
        }
        if (Request["dates"] != null)
        {
            DateTime date = Convert.ToDateTime(Request["dates"]);
            SqlWhere += " and custorder.OrderDateTime between '" + date + "' and '" + date.AddDays(1) + "'";
        }

        int reveint2 = HjNetHelper.GetQueryInt("reveint2", 0);
        if (reveint2 > 0)
        {
            SqlWhere += " and custorder.reveint2=1";
        }
        int deliversiteid = HjNetHelper.GetQueryInt("deliversiteid", 0);
        if (deliversiteid > 0)
        {
            SqlWhere += " and deliversiteid=10";
        }


        // Response.Write(SqlWhere);
    }


    protected void rtpOrderlist_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string type = e.CommandName;
        switch (type)
        {
            case "del":
                //判断权限
                int _rs = WebUtility.checkOperator(4);
                if (_rs == 0)
                {
                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "alert('无操作权限','success','true',5);init();");
                    return;
                }
                if (bll.DelList(e.CommandArgument.ToString(), UserHelp.GetAdmin().AdminName) > 0)//只是隐藏了,并没删除
                {
                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:删除成功!','250','150','true','2000','true','text');init();");
                    BindData(ordersort);
                }
                else
                {
                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:删除失败!','250','150','true','2000','true','text');init();");
                }
                break;
            case "print":
                {
                    FeYinPrinter p = new FeYinPrinter(e.CommandArgument.ToString());
                    p.SendCustomMessage();
                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','2000','true','text');init();");
                    break;
                }

            case "OrderChecker":
                {
                    string sql = "UPDATE dbo.Custorder SET OrderChecker = 1 ,settleuser = '" + UserHelp.GetAdmin().AdminName + "' WHERE unid = " + e.CommandArgument;
                    WebUtility.excutesql(sql);
                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','2000','true','text');init();");
                    BindData(ordersort);
                    break;
                }

            case "OrderTimeOut":
                {
                    CustorderInfo order = bll.GetModel(Convert.ToInt32(e.CommandArgument));

                    int new_deliversiteid = 10;
                    if (order.deliversiteid == 10)
                    {
                        new_deliversiteid = 1;
                    }

                    string sql = "UPDATE dbo.Custorder SET deliversiteid = " + new_deliversiteid + " WHERE unid = " + e.CommandArgument;
                    WebUtility.excutesql(sql);


                    deliverlogInfo item = new deliverlogInfo();
                    item.admin = UserHelp.GetAdmin().AdminName;
                    item.optime = DateTime.Now;
                    item.eventname = "修改";
                    item.columntext = "超时标志";
                    item.columnname = "deliversiteid";
                    item.oldvalue = order.deliversiteid.ToString();
                    item.newvalue = new_deliversiteid.ToString();
                    item.reveint1 = 0;
                    item.reveint2 = 0;
                    item.revevar1 = order.orderid;
                    item.revevar2 = TableENUM.Custorder.ToString();

                    new deliverlog().Add(item);


                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','2000','true','text');init();");
                    BindData(ordersort);
                    break;
                }


            case "over":
                {
                    string[] ids = e.CommandArgument.ToString().Split('_');

                    new OrderServiceImpl().manComplete(ids[0], Convert.ToInt32(ids[1]));

                    bll.AddOrderRecord(ids[0], 3, UserHelp.GetAdmin().AdminName, "客服列表界面完成订单");

                    AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','2000','true','text');init();");
                    BindData(ordersort);


                }

                break;
        }
    }

    protected void DelList_Click(object sender, EventArgs e)
    {
        //判断权限
        int _rs = WebUtility.checkOperator(4);
        if (_rs == 0)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "alert('无操作权限','success','true',5);init();");
            return;
        }

        string IdList = this.hdDels.Value;

        IList<CustorderInfo> orders = bll.GetOrderDeliverIDs(IdList);

        if (bll.DelList(IdList, UserHelp.GetAdmin().AdminName) > 0)
        {
            Deliver daldeliver = new Deliver();
            foreach (var item in orders)
            {
                if (item.deliverid > 0)
                {
                    NoticeHelper notice = new NoticeHelper(Context, item.deliverid.ToString());
                    notice.sendOrderByDeliveryid(item.deliverid);

                    daldeliver.InitWorkState(item.deliverid);

                    //string sql = "UPDATE dbo.Deliver SET workstate = 10 WHERE DataId = " + item.deliverid;
                    //WebUtility.excutesql(sql);


                }
            }


            AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:删除成功!','250','150','true','1000','true','text');init();");
            BindData(ordersort);
        }
        else
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:删除失败!','250','150','true','1000','true','text');init();");
        }
    }

    /// <summary>
    /// 批量地址复核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void addressCheck_Click(object sender, EventArgs e)
    {
        string IdList = this.hdDels.Value;


        string sql = "UPDATE dbo.Custorder SET OrderChecker = 1 ,settleuser = '" + UserHelp.GetAdmin().AdminName + "' WHERE unid in (" + IdList + ") and OrderChecker=0";
        WebUtility.excutesql(sql);

        AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','1000','true','text');init();");
        BindData(ordersort);

    }


    protected void dyList_Click(object sender, CommandEventArgs e)
    {
        //判断权限
        int _rs = WebUtility.checkOperator(5);
        if (_rs == 0)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "alert('无操作权限','success','true',5);init();");
            return;
        }
        string IdList = this.hdDels.Value;
        if (IdList == "")
        {

            IdList = ((LinkButton)sender).CommandArgument;
        }
        WebUtility.FixsetCookie("dy", IdList, 1);
        Response.Redirect("printorder.aspx");
    }


    public string gethurry(string oid)
    {
        hurryorderInfo model = new Hangjing.SQLServerDAL.hurryorder().GetModel(oid);
        string rs = "";
        if (model.oid != null)
        {
            rs = "<font color='red'>" + model.Ccount + "(" + model.addtime + ")</font>";
        }
        else
        {
            rs = "无";
        }
        return rs;
    }

    protected void ddlFunction_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList drop = sender as DropDownList;

        Repeater rep = drop.Parent.Parent as Repeater;
        int n = ((RepeaterItem)drop.Parent).ItemIndex;
        string dataid = ((HiddenField)(rep.Items[n].FindControl("hidOrderId"))).Value;
        CustorderInfo model = bll.GetModel(Convert.ToInt32(dataid));

        if (model.OrderStatus == 70)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:已经完成的订单不能修改了。','250','150','true','1000','true','text');init();");
            return;
        }
        if (model.OrderStatus == 50)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:此订单已经锁定，不能操作。','250','150','true','1000','true','text');init();");
            return;
        }

        if (bll.UpdataState(Convert.ToInt32(dataid), Convert.ToInt32(drop.SelectedValue)) > 0)
        {
            bll.UpdataState(Convert.ToInt32(dataid), UserHelp.GetAdmin().AdminName);
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:更新状态成功!','250','150','true','1000','true','text');init();");

            //加积分 TODO：是否在此处加积分 
            if (drop.SelectedValue == "70" && model.OrderStatus != 70)//避免多次加分
            {
                bll.AddPoint(model.Unid.ToString());
            }

            BindData(ordersort);
        }
        else
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:更新状态失败!','250','150','true','1000','true','text');init();");
        }
    }

    protected void ot(object sender, EventArgs e)
    {
        ordersort = "OrderDateTime";//custorder.OrderDateTime
        BindData(ordersort);
    }

    protected void os(object sender, EventArgs e)
    {
        ordersort = "OrderStatus";
        BindData(ordersort);
    }

    /// <summary>
    /// timeer event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        string sql = " OrderStatus  in (1,2,7) and Custorder.delflag=0";
        sql = new RightsTool().getOrderWhere(sql);
        int count = bll.GetCount(sql);
        if (count != 0)
        {
            AlertScript.RegScript(this.Page, UpdatePanel1, "play(" + count + ");");
        }
        else
        {
            AlertScript.RegScript(this.Page, UpdatePanel1, "play(0);");
        }
        BindData(ordersort);

    }

    /// <summary>
    /// 翻页事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {

        BindData(ordersort);
    }


    protected void btExport_Click(object sender, EventArgs e)
    {
        //判断权限
        int _rs = WebUtility.checkOperator_super(5);
        if (_rs == 0)
        {
            AlertScript.RegScript(this.Page, "alert('无操作权限','success','true',5);init();");
            return;
        }
        WebUtility.FixsetCookie("SearchOrderSqlWhere", SqlWhere, 1);
        Response.Redirect("SearchExcelOrder.aspx?type=1");
    }

    /// <summary>
    /// 批量超时
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void timeout_Click(object sender, EventArgs e)
    {
        string IdList = this.hdDels.Value;


        string sql = "UPDATE dbo.Custorder SET deliversiteid = 10  WHERE unid in (" + IdList + ") and deliversiteid <  10 ";
        WebUtility.excutesql(sql);


        AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','1000','true','text');init();");
        BindData(ordersort);

    }

    /// <summary>
    /// 批量非超时
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void notimeout_Click(object sender, EventArgs e)
    {
        string IdList = this.hdDels.Value;


        string sql = "UPDATE dbo.Custorder SET deliversiteid = 1  WHERE unid in (" + IdList + ") and deliversiteid =  10 ";
        WebUtility.excutesql(sql);


        AlertScript.RegScript(this.Page, this.UpdatePanel1, "tipsWindown('提示信息','text:操作成功!','250','150','true','1000','true','text');init();");
        BindData(ordersort);

    }

    /// <summary>
    /// 批量设置折扣
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void setsalary_Click(object sender, EventArgs e)
    {
        string ordertime = tbaddsalary.Text;
        if (ordertime.Length == 0)
        {
            AlertScript.RegScript(this.Page, UpdatePanel1, "alert('请输入订单新时间','text:操作成功!','250','150','true','1000','true','text');init();");
            return;
        }

        //判断权限
        int _rs = WebUtility.checkOperator_super(6);
        if (_rs == 0)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "alert('无操作权限','success','true',5);init();");
            return;
        }

        Button bt = (Button)sender;
        string sql = "update Custorder set OrderDateTime = '" + tbaddsalary.Text + "' where ";
        if (bt.ID == "btselectadd")
        {
            string IdList = this.hdDels.Value;
            sql += " unid in (" + IdList + ")";
        }
        else
        {
            sql += " " + SqlWhere;
        }

        if (WebUtility.excutesql(sql) > 0)
        {
            AlertScript.RegScript(this.Page, UpdatePanel1, "alert('设置成功','text:操作成功!','250','150','true','1000','true','text');init();");
            BindData(ordersort);
        }
        else
        {
            AlertScript.RegScript(this.Page, UpdatePanel1, "alert('设置失败','text:操作失败!','250','150','true','1000','true','text');init();");
        }
    }
}
